<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app"></div>
  <script src="../packages/reactivity/dist/reactivity.global.js"></script>
  <script>
    const { reactive, readonly, toRaw, markRaw, effect, ref} = VueReactivity
    const state = reactive({name: 'jw', a: ref(100)})

    debugger
    delete state.name // proxy中还有delete监听器，deleteProperty方法，删除老值，触发trigger

    debugger
    'name' in state // proxy中还有has监听器，触发has方法：1. 不关心symbol（直接return），2. 依赖收集

    // for in，触发proxy的ownKeys：依赖收集
    for (const key in object) { }

    // set：readonly、以前是ref现在不是ref 不能改；
    state.a = 100 // 不能修改

    // 屏蔽原型链的set：为什么不考虑原型链的set；收集依赖proto不会被递归为响应式
    // let obj = {}
    // let proto = {a:1}
    // const protoProxy = new Proxy(proto, {
    //   get(target, key, receiver) {
    //     return Reflect.get(target, key, receiver)
    //   },
    //   set(target, key, value, receiver) {
    //     return Reflect.set(target, key,value, receiver)
    //   }
    // })
    // Object.setPrototypeOf(obj, protoProxy)
    // const objProxy = new Proxy(obj, {
    //   get(target, key, receiver) {
    //     return Reflect.get(target, key, receiver)
    //   },
    //   set(target, key, value, receiver) {
    //     return Reflect.set(target, key,value, receiver)
    //   }
    // })
    // obj.a = 100 // 会触发两次set
  </script>
</body>
</html>